﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Configuration;
using System.Text;
using DAL;
public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public string GetWebUrl()
    {
        return UIConfig.WebUrl;
    }
    //频道14 ，公告
    private string Board()
    {
        StringBuilder sb = new StringBuilder();
        DataSet ds = DbHelperSQL.Query("select top 5 * from T_Article where catId in(select OrderId from T_ArticleCategory where ChannelId=14) order by artDate desc ");

        sb.Append("<table cellspacing='0' cellpadding='0' width='98%' align='center' border='0'>");
        sb.Append("<tr>");
        sb.Append("<td width='54%'>");
        sb.Append("<table cellspacing='0' cellpadding='0' border='0'>");
        sb.Append("<tr>");
        sb.Append("<td align='middle'>");
        sb.Append("<img height='34' src='" + ResolveUrl("~/Skin/webui_07AT/searpic.gif") + "' width='56'>");
        sb.Append("</td>");
        sb.Append("<td style='padding-right: 8px; color: #f1f7fa'>");
        sb.Append("<input type='radio' value='Article' name='ModuleName'>");
        sb.Append("文章");
        sb.Append("<input type='radio' value='Photo' name='ModuleName'>");
        sb.Append("图片");
        sb.Append("<input id='Field' type='hidden' value='Title' name='Field'>");
        sb.Append("</td>");
        sb.Append("<td class='classTd'>");
        sb.Append("<input id='Keyword' style='border-right: 0px; border-top: 0px; font-size: 9pt; background: none transparent scroll repeat 0% 0%;  margin-left: 24px; border-left: 0px; width: 158px; border-bottom: 0px; height: 16px'  maxlength='50' value='关键字' name='Keyword'>");
        sb.Append("</td>");
        sb.Append("<td align='middle' width='78'>");
        sb.Append("<input type='image' src='" + ResolveUrl("~/Skin/webui_07AT/searbut.gif") + "' align='middle'  name='Submit'>");
        sb.Append("</td>");
        sb.Append("</tr>");
        sb.Append("</table>");
        sb.Append("</td>");
        sb.Append("<td width='46%'>");
        sb.Append("<table cellspacing='0' cellpadding='0' width='98%' border='0'>");
        sb.Append("<tr>");
        sb.Append("<td width='17'>");
        sb.Append("<img height='20' src='" + ResolveUrl("~/Skin/webui_07AT/anu1.gif") + "' width='17'>");
        sb.Append("</td>");
        sb.Append("<td class='classTd1'>");
        sb.Append("<div style='overflow: hidden; height: 20px'>");
        sb.Append("<marquee onmouseover='this.stop()' onmouseout='this.start()' scrollamount='1' scrolldelay='4' width='390' height='20' align='left'>  &nbsp;&nbsp;");
        if (ds.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                sb.Append("&nbsp;&nbsp;<a class=\"AnnounceBody2\" href=\"#\" onclick=\"javascript:window.open(Article/" + ds.Tables[0].Rows[i]["OrderId"].ToString() + ".html', 'newwindow', 'height=440, width=400, toolbar=no, menubar=no, scrollbars=auto, resizable=no, location=no, status=no')\"");
                sb.Append("title=\"" + ds.Tables[0].Rows[i]["ArtTitle"].ToString() + "\">" + ds.Tables[0].Rows[i]["ArtTitle"].ToString() + "&nbsp;&nbsp;[" + ds.Tables[0].Rows[i]["ArtAuthor"].ToString() + "&nbsp;&nbsp;" + Convert.ToDateTime(ds.Tables[0].Rows[i]["ArtDate"]).ToString("yyyy年MM月dd日") + "]</a>&nbsp;&nbsp;");
            }
        }
        sb.Append("&nbsp;</marquee>");
        sb.Append("</div>");
        sb.Append("</td>");
        sb.Append("<td width='4'>");
        sb.Append("<img height='20' src='Skin/webui_07AT/anu3.gif' width='4'>");
        sb.Append("</td>");
        sb.Append("</tr>");
        sb.Append("</table>");
        sb.Append("</td>");
        sb.Append("</tr>");
        sb.Append("</table>");

        return sb.ToString();
    }
    private string getSumMenu(string id)
    {
        StringBuilder sb = new StringBuilder();
        DataSet dsItems = DbHelperSQL.Query("select * from T_Menu where Items=" + id + "");
        if (dsItems.Tables[0].Rows.Count > 0)
        {
            sb.Append("<div class=\"divsubmenu\">");
            for (int i = 0; i <= dsItems.Tables[0].Rows.Count - 1; i++)
            {
                sb.Append("<a href=\"Article/List_" + dsItems.Tables[0].Rows[i]["Id"].ToString() + ".html\">" + dsItems.Tables[0].Rows[i]["Name"].ToString() + "</a>");

            } sb.Append("</div>");
        }
        return sb.ToString();
    }
    //导航
    public string Menu()
    {
        StringBuilder sb = new StringBuilder();
        DataSet ds = new MenuDal().GetList("shown=1 and Items=0");
        if (ds.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                if (i == 0)
                    sb.Append("<a class=\"Channel2\"");
                else
                    sb.Append("<a class=\"Channel\"");
                sb.Append(" href=\"" + ResolveUrl("~/"+ds.Tables[0].Rows[i]["URL"].ToString()) + "\" id=\"mtab" + (i + 1).ToString() + "\" onmouseover=\"setTab('mtab'," + (i + 1).ToString() + ",10)\">" + ds.Tables[0].Rows[i]["Name"].ToString() + "</a>");
            }
        }
        return sb.ToString();
    }

    //子导航
    public string SubMenu()
    {
        StringBuilder sb = new StringBuilder();
        DataSet ds = new MenuDal().GetList("shown=1 and Items=0");
        if (ds.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                sb.Append("<tr id=\"hi_mtab_" + (i + 1).ToString() + "\"");
                if (i == 0)
                    sb.Append("style=\"display:block;\">");
                else
                    sb.Append("style=\"display: none;\">");
                sb.Append("<td class=\"classboxl\">");
                sb.Append("</td>");
                sb.Append("<td class=\"classbox\" id=\"newclassmenu" + (i + 1).ToString() + "\" align=\"center\">");
                if (i == 0)
                    sb.Append(Board());
                else
                    sb.Append(getSumMenu(ds.Tables[0].Rows[i]["Id"].ToString()));
                sb.Append("</td>");
                sb.Append("<td class=\"classboxr\">");
                sb.Append("</td>");
                sb.Append("</tr>");
            }
        }
        return sb.ToString();
    }


}
